package nl.project.source;

import java.io.UnsupportedEncodingException;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

/**
 * @author Wouter
 * 
 */

public class Mailer {
	
	public void sendMail(String receiver, String message) throws UnsupportedEncodingException{
		Properties props = new Properties();
        Session session = Session.getDefaultInstance(props, null);
        String subject = "Notificatie inplanning ouderenavond";
	        try {
	            Message msg = new MimeMessage(session);
	            msg.setFrom(new InternetAddress("admin@school.com", "School administratie"));
	            msg.addRecipient(Message.RecipientType.TO, new InternetAddress(receiver, "Gebruiker"));
	            msg.setSubject(subject);
	            msg.setText(message);
	            Transport.send(msg);
	
	        } catch (AddressException e) {
	            // ...
	        } catch (MessagingException e) {
	            // ...
	        }
	}
}
